package com.kailong.servlet.seat;

import com.kailong.dao.admin.ManageSeatDao;
import com.kailong.pojo.Seat;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
@WebServlet("/admin/seatSelectAll")
public class SeatSelectAll extends HttpServlet {
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        int cpage = 1;//
        int count = 10;//
        String floor = request.getParameter("floor");
        String square = request.getParameter("square");
        String tstate = request.getParameter("tstate");
        String cp = request.getParameter("cp");
        if(cp!=null){
            cpage = Integer.parseInt(cp);
        }
        int arr[]  = ManageSeatDao.totalPage(count,floor,square);
        //获取所有用户记录
        ArrayList<Seat> list = ManageSeatDao.selectAll(cpage,count,floor,square,tstate);
        //放到请求对象域
        request.setAttribute("seatlist",list);
        request.setAttribute("tsum",arr[0]);
        request.setAttribute("tpage",arr[1]);
        request.setAttribute("cpage",cpage);
        if(floor!=null && square != null){
            request.setAttribute("searchParams","&floor=" + floor + "&square=" + square);
        }

        request.getRequestDispatcher("adminSeatSelect.jsp").forward(request,response);
    }
}
